/*
 * Program that checks if two Strings are annagrams or not.	
 */
import java.util.*;
public class Annagram{
	public static void main(String[] args){
		//Initialize input form keyboard
		Scanner in = new Scanner(System.in);
		
		//Get two phrases that will be compared
		System.out.println("Input first phrase");
		String phrase1 = in.nextLine();
		System.out.println("Input second phrase");
		String phrase2 = in.nextLine();
	
		//Set both strings to lower case
		phrase1 = phrase1.toLowerCase();
		phrase2 = phrase2.toLowerCase();
			
		//Transform both strings to array of chars
		char[] line1 = new char[phrase1.length()];
		char[] line2 = new char[phrase2.length()];
		
		for (int i = 0; i < phrase1.length(); i++)
			line1[i] = phrase1.charAt(i);
		
		for (int i = 0; i < phrase2.length(); i++)
			line2[i] = phrase2.charAt(i);
		
		// Sort arrays in alphabetical order
		Arrays.sort(line1);
		Arrays.sort(line2);
		
		// Transform sorted arrays to string
		phrase1 = new String(line1);
		phrase2 = new String(line2);
				
		// Trim all white spaces(after sorting they are at the beginning of the strings)
		phrase1 = phrase1.trim();
		phrase2 = phrase2.trim();
		
		// If resulting strings are equal then initial strings are annagrams
		if (phrase1.equals(phrase2))
			System.out.println("Prases are annagrams");
		else
			System.out.println("Prases are not annagrams");
	}
}